package chpt04;

class Foo{
	int id;
	public static void show() {
		System.out.println("Static Method in Foo");
	}
	public void test() {
		System.out.println("Instance Method in Foo");
	}
	@Override
	public String toString() {
		return "Foo [id=" + id + "]";
	}
}

class FooSon extends Foo{
	int id = 100; // 与父类属性同名，隐藏了父类的id
	public static void show() {
		System.out.println("Static Method in FooSon");
	}
	@Override
	public String toString() { // 覆盖了父类的同名方法
		return "FooSon [id=" + id + "]";
	}
	public void showMe() {
		System.out.println("super.id = " + super.id);
		System.out.println("FooSon.id = " + id);
		System.out.println(super.toString());
		System.out.println(toString());
		test();  // 也可使用super.test()
	}
}

public class SuperHidingTest {
	public static void main(String[] args) {
		FooSon fs = new FooSon();
		fs.showMe();
	}

	private static void testHidingStaticMethod() {
		Foo f = new Foo();
		FooSon fs = new FooSon();
		Foo.show();     // 同f.show();
		FooSon.show();  // 同fs.show();
		f.show();
		fs.show();
	}

}
